package com.innovations.inn.service.impl;

import java.util.List;

import com.innovations.common.utils.uuid.IdGeneratorSnowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.innovations.inn.mapper.ResearchOutcomesClassifyMapper;
import com.innovations.inn.domain.ResearchOutcomesClassify;
import com.innovations.inn.service.IResearchOutcomesClassifyService;

/**
 * 科研成果分类Service业务层处理
 * 
 * @author dp
 * @date 2024-08-09
 */
@Service
public class ResearchOutcomesClassifyServiceImpl implements IResearchOutcomesClassifyService 
{
    @Autowired
    private ResearchOutcomesClassifyMapper researchOutcomesClassifyMapper;
    @Autowired
    IdGeneratorSnowflake idGeneratorSnowflake;

    /**
     * 查询科研成果分类
     * 
     * @param classifyId 科研成果分类主键
     * @return 科研成果分类
     */
    @Override
    public ResearchOutcomesClassify selectResearchOutcomesClassifyByClassifyId(Long classifyId)
    {
        return researchOutcomesClassifyMapper.selectResearchOutcomesClassifyByClassifyId(classifyId);
    }

    /**
     * 查询科研成果分类列表
     * 
     * @param researchOutcomesClassify 科研成果分类
     * @return 科研成果分类
     */
    @Override
    public List<ResearchOutcomesClassify> selectResearchOutcomesClassifyList(ResearchOutcomesClassify researchOutcomesClassify)
    {
        return researchOutcomesClassifyMapper.selectResearchOutcomesClassifyList(researchOutcomesClassify);
    }

    /**
     * 新增科研成果分类
     * 
     * @param researchOutcomesClassify 科研成果分类
     * @return 结果
     */
    @Override
    public int insertResearchOutcomesClassify(ResearchOutcomesClassify researchOutcomesClassify)
    {
        return researchOutcomesClassifyMapper.insertResearchOutcomesClassify(researchOutcomesClassify);
    }

    /**
     * 修改科研成果分类
     * 
     * @param researchOutcomesClassify 科研成果分类
     * @return 结果
     */
    @Override
    public int updateResearchOutcomesClassify(ResearchOutcomesClassify researchOutcomesClassify)
    {
        return researchOutcomesClassifyMapper.updateResearchOutcomesClassify(researchOutcomesClassify);
    }

    /**
     * 批量删除科研成果分类
     * 
     * @param classifyIds 需要删除的科研成果分类主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesClassifyByClassifyIds(Long[] classifyIds)
    {
        return researchOutcomesClassifyMapper.deleteResearchOutcomesClassifyByClassifyIds(classifyIds);
    }

    /**
     * 删除科研成果分类信息
     * 
     * @param classifyId 科研成果分类主键
     * @return 结果
     */
    @Override
    public int deleteResearchOutcomesClassifyByClassifyId(Long classifyId)
    {
        return researchOutcomesClassifyMapper.deleteResearchOutcomesClassifyByClassifyId(classifyId);
    }

    /**
     * 实体数据补全
     *
     * @param researchOutcomesClassify 实体
     * @param userId       用户id
     * @param crateType    创建类型 1：新增 2：修改
     */
    @Override
    public void completeData(ResearchOutcomesClassify researchOutcomesClassify, Long userId, Integer crateType) {
        //主键
        if (researchOutcomesClassify.getClassifyId() == null || "".equals(researchOutcomesClassify.getClassifyId())) {
            researchOutcomesClassify.setClassifyId(idGeneratorSnowflake.nextId());
        }
//        //创建人、创建时间
//        if (crateType == 1) {
//            if (researchOutcomesClassify.getCreateBy() == null || "".equals(researchOutcomesClassify.getCreateBy())) {
//                researchOutcomesClassify.setCreateBy(userId);
//            }
//            if (researchOutcomesClassify.getCreateTime() == null) {
//                researchOutcomesClassify.setCreateTime(DateUtils.getNowDate());
//            }
//        }
//        //修改人
//        if (researchOutcomesClassify.getModifyBy() == null) {
//            researchOutcomesClassify.setModifyBy(userId);
//        }
//        //修改时间
//        if (researchOutcomesClassify.getModifyTime() == null) {
//            researchOutcomesClassify.setModifyTime(DateUtils.getNowDate());
//        }
    }
}
